package com.klm.config;

import com.klm.cache.TranslateCacheManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@EnableScheduling
public class TranslateCacheInitConfig implements ApplicationRunner {
    
    @Autowired
    private TranslateCacheManager cacheManager;

    @Override
    public void run(ApplicationArguments args) {
        log.info("[Trans. plugin] 开始初始化翻译缓存");
        try {
            // 预热缓存
            cacheManager.warmUpCache();
            log.info("[Trans. plugin] 翻译缓存初始化完成");
        } catch (Exception e) {
            log.error("[Trans. plugin] 翻译缓存初始化失败", e);
        }
    }
} 